{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-09T15:32:18.310431Z",
     "start_time": "2020-09-09T15:32:16.959261Z"
    }
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "903ac71f6d0247a98b120a6ddf569ed7",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt  # 绘图用的模块\n",
    "from mpl_toolkits.mplot3d import Axes3D  # 绘制3D坐标的函数\n",
    "import numpy as np\n",
    "\n",
    "# matplotlib设置输出矢量图\n",
    "%matplotlib inline\n",
    "%config InlineBackend.figure_format = 'svg'\n",
    "\n",
    "# 可交互的matplotlib\n",
    "%matplotlib widget\n",
    "\n",
    "def fun(x, y):\n",
    "    return np.power(x, 2) + np.power(y, 2)\n",
    "\n",
    "\n",
    "fig1 = plt.figure()  # 创建一个绘图对象\n",
    "ax = Axes3D(fig1)  # 用这个绘图对象创建一个Axes对象(有3D坐标)\n",
    "X, Y = np.mgrid[-2:2:40j, -2:2:40j]  # 从-2到2分别生成40个取样坐标，并作满射联合\n",
    "Z = fun(X, Y)  # 用取样点横纵坐标去求取样点Z坐标\n",
    "plt.title(\"This is main title\")  # 总标题\n",
    "ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=plt.cm.coolwarm, alpha=0.5)  # 用取样点(x,y,z)去构建曲面\n",
    "ax.set_xlabel('x label', color='r')\n",
    "ax.set_ylabel('y label', color='g')\n",
    "ax.set_zlabel('z label', color='b')  # 给三个坐标轴注明\n",
    "plt.show()  # 显示模块中的所有绘图对象"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
